﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Text;

public partial class demo_fileUpload_fileUpload : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) 
    {
        string pathori = Server.MapPath("/upload/sys/image/");
        string filename = System.Guid.NewGuid().ToString() + ".jpg";
        string path = Path.Combine(pathori, filename);
        string re = "/upload/sys/image/" + filename;

        //找到目标文件对象
        HttpPostedFile uploadFile = Request.Files["Fdata"];

        // 如果有文件, 则保存到一个地址
        if (uploadFile.ContentLength > 0)
        {
            uploadFile.SaveAs(path);
        }
        string json = Dos.Common.JSON.ToJSON(new { success = true, path = re });
        //Response.ContentType = "application/json";
        //Response.ContentEncoding = Encoding.UTF8;
        Response.Write(json);    //可以返回一个JSON字符串, 在客户端做更多处理
        Response.End();
    }
}